package com.wanmait.wisdom.manage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.wisdom.entity.Bulletin;
import com.wanmait.wisdom.manage.service.ManageBulletinService;
import com.wanmait.wisdom.mapper.BulletinMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class ManageBulletinServiceImpl extends ServiceImpl<BulletinMapper, Bulletin> implements ManageBulletinService {
    @Resource
    private BulletinMapper bulletinMapper;

    @Override
    public void addBulletin(Bulletin bulletin) {
        bulletinMapper.insertSelective(bulletin);
    }

    @Override
    public PageInfo<Bulletin> findAllBulletin(String title, Integer pageNum, Date startTime, Date endTime,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
//        List<Bulletin> bulletinList = bulletinMapper.list(bulletin,startTime,endTime);
//        return new PageInfo<>(bulletinList,9);

        return new PageInfo<Bulletin>(bulletinMapper.list(title,startTime,endTime),9);
    }
}
